﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="UClaimDemageControlListEasyUI.aspx.cs" Inherits="IHISCETeim.Web.MachineSys.UserModel.UClaimDemageControlListEasyUI" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <link rel="stylesheet" type="text/css" href="../EasyUI/themes/default/easyui.css"/>
	<link rel="stylesheet" type="text/css" href="../EasyUI/themes/icon.css" />
	<script type="text/javascript" src="../js/jquery-1.7.2.min.js"></script>   
	<script type="text/javascript" src="../EasyUI/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="../EasyUI/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript" src="../EasyUI/easyui-formatter_20140718.js"></script>
     <link href="../themes/css/jquery.autocomplete.css" rel="stylesheet" type="text/css" />
    <script src="../js/DWZ/jquery.autocomplete.js" type="text/javascript"></script>

    <script type="text/javascript">
        ///自适应宽高
       $(window).resize(function(){		    
             $("#tab_list").datagrid({
                    width: '100%',
                    height: $(parent.document).find(".tabsPageContent").height() - 11 > 0 ? $(parent.document).find(".tabsPageContent").height() - 11 : 500,
             }); 
	    });
        //权限处理
        var $powers={
            "r新增":<%=HasPowerEasyUI(IHISCETeim.Web.Permission.新增) %>,
            "r修改":<%=HasPowerEasyUI(IHISCETeim.Web.Permission.修改) %>,
            "r删除":<%=HasPowerEasyUI(IHISCETeim.Web.Permission.删除) %>,
            "r导出":<%=HasPowerEasyUI(IHISCETeim.Web.Permission.导出) %>,
            "r索赔管控_索赔录入":<%=HasPowerEasyUI(IHISCETeim.Web.Permission.索赔管控_索赔录入) %>,
            "r索赔管控_结算录入":<%=HasPowerEasyUI(IHISCETeim.Web.Permission.索赔管控_结算录入) %>,
            "r索赔管控_向供应商索赔统计":<%=HasPowerEasyUI(IHISCETeim.Web.Permission.索赔管控_向供应商索赔统计) %>,
            "r索赔管控_差异分析":<%=HasPowerEasyUI(IHISCETeim.Web.Permission.索赔管控_差异分析) %>
        };

        $(document).ready(function () {
           

            var $tab_toolbar=$("#tab_toolbar");
            $tab_toolbar.find("a").each(function(){
                var $per=$(this).attr("Permission");
                var pt= $powers[$per]==undefined || null?true:$powers[$per];
                $(this).linkbutton(pt?'enable': 'disable');
            })

            //自动完成
            $(".autocomplete").each(function () {
                var $this = $(this);
                var url = unescape($this.attr("autocompletehref"));
                $this.autocomplete(url);
            });
            //加载数据
            InitGird();           
        })
        //加载列表数据
        function InitGird() {
            $('#tab_list').datagrid({               
                url: location.href, //请求数据的页面
                sortName: 'ClaimsNumber', //排序字段
                sortOrder: 'desc', //排序类型
                idField: 'ClaimsNumber', //标识字段,主键
                iconCls: '', //标题左边的图标
                width: '100%', //宽度    
                height: $(parent.document).find(".tabsPageContent").height() - 11 > 0 ? $(parent.document).find(".tabsPageContent").height() - 11 : 500,
                nowrap: false, //是否换行，True 就会把数据显示在一行里
                striped: true, //True 奇偶行使用不同背景色
                collapsible: false, //可折叠
                singleSelect: true, //是否只能选中一条
                remoteSort: true, //定义是否从服务器给数据排序
                frozenColumns: [[//冻结的列，不会随横向滚动轴移动
                	{ title: '品情单号', field: 'ClaimsNumber', width: 80, sortable: true },
                    {title: '机号', field: 'SerialNumber', width: 70 }
				]],
                columns: [[
                    { title: '接到故障日', field: 'FaultDate', width: 90, sortable: true ,formatter:formatterdate},
                    { title: '代理商', field: 'AgentName', width: 100, sortable: true },
                    { title: '工作小时', field: 'WorkHour', width: 70},
                    { title: 'IHISCE索赔件成本', field: 'SendPartCost', width: 120,formatter:milliformatter },
                    { title: '发货运费', field: 'SendPartTransportCost', width: 80,formatter:milliformatter},
                    { title: '代理商结算费用', field: 'AgentTotalCost2', width: 120, 
                        formatter: function(value, row, index){
//                            if(row.ClaimsNumber==undefined)
//                                return value;
                            //代理商结算费用=AgentTotalCost-SendPartCost-SendPartTransportCost
                            var $v= parseFloat(row.AgentTotalCost)-parseFloat(row.SendPartCost)-parseFloat(row.SendPartTransportCost);
                            if(row.AgentIsSubmit)
                                return "<b style='color:red'>"+milliformatter($v)+"</b>";
                            else
                                return milliformatter($v);
                        }
                    },
                    { title: '批复时间', field: 'PiFuDate', width: 90, sortable: true },
                    { title: '索赔成本', field: 'AgentTotalCost', width: 90, sortable: true ,
                        formatter:function(value, row, index){
                            if(row.ClaimsNumber==undefined)
                                return value;
                            return '<a href="#"  title="索赔成本" onclick="onAgentTotalCostClick(\''+row.ClaimsNumber+'\'); return false;">'+value+'</a>';//事件处理
                        }
                    },
                    { title: '索赔总金额', field: 'SupplerTotalCostRMB', width: 90, sortable: true ,
                        formatter:function(value, row, index){
                            var AgentTotalCost=row.AgentTotalCost;
                            if(AgentTotalCost<=0)
                                return value;
                            if(row.ClaimsNumber==undefined)
                                return value;

                            return '<a href="#" title="索赔总金额" onclick="onSupplerTotalCostRMBClick(\''+row.ClaimsNumber+'\'); return false;">'+value+'</a>';//事件处理
                        }
                    },
                    { title: '结算金额', field: 'FinalTotalCostRMB', width: 90, sortable: true ,
                        formatter:function(value, row, index){
                            var SupplerTotalCostRMB=row.SupplerTotalCostRMB;
                            if(SupplerTotalCostRMB<=0)
                                return value;
                            if(row.ClaimsNumber==undefined)
                                return value;
                            return '<a href="#" title="结算金额" onclick="onFinalTotalCostRMBClick(\''+row.ClaimsNumber+'\'); return false;">'+value+'</a>';//事件处理
                        }
                    },
                    { title: '索赔成本差异', field: 'FinalDiffAmount', width: 90, sortable: true ,
                        formatter:function(value, row, index){
                            if(row.ClaimsNumber==undefined)
                                return value;
                            return '<a href="#" title="索赔成本差异" onclick="onFinalDiffAmountClick(\''+row.ClaimsNumber+'\'); return false;">'+value+'</a>';//事件处理
                        }
                    },
                    { title: '索赔收入差异', field: 'SupplerDiffAmount', width: 90, sortable: true ,
                        formatter:function(value, row, index){
                            if(row.ClaimsNumber==undefined)
                                return value;
                            return '<a href="#"  title="索赔收入差异" onclick="onSupplerDiffAmountClick(\''+row.ClaimsNumber+'\'); return false;">'+value+'</a>';//事件处理
                        }
                    }
                ]],
                toolbar: "#tab_toolbar",
                queryParams: { "action": "query" },
                pagination: true, //是否开启分页
                pageNumber: 1, //默认索引页
                pageSize: <%=numPerPage %>, //默认一页数据条数
                pageList:<%=SetnumPerPage() %>,
                rownumbers: true, //行号
                showFooter: true
            });

        }       
       
        /*每行的操作处理*/
        //索赔成本
        function onAgentTotalCostClick(ClaimsNumber)
        {
            if(!$powers["r修改"])
            {
                $.messager.alert('提示','您没有权限进行此操作');
                return false;
            }
            var rel="UClaimDemageControlEdit";
            var url="UserModel/UClaimDemageControlEdit.aspx?ClaimsNumber="+ClaimsNumber;
            var title="修改代理商索赔完成报告单";
            var options = {width:850,height:450,max:false,mask:true,maxable:false,minable:false,fresh:true,resizable:false,drawable:true};
            top.$.pdialog.open(url, rel, title, options);
        }
        //索赔总金额
        function onSupplerTotalCostRMBClick(ClaimsNumber)
        {
            if(!$powers["r索赔管控_索赔录入"])
            {
                $.messager.alert('提示','您没有权限进行此操作');
                return false;
            }
            var rel="UClaimDemageControlUpdateSupplerDetail";
            var url="UserModel/UClaimDemageControlUpdateSupplerDetail.aspx?ClaimsNumber="+ClaimsNumber;
            var title="向供应商索赔明细[品情单号:"+ClaimsNumber+"]";
           // var options = {width:850,height:450,max:false,mask:true,maxable:false,minable:false,fresh:true,resizable:false,drawable:true};
            //top.$.pdialog.open(url, rel, title, options);
            top.navTab.openTab(rel, url, { title: title, fresh: true, external: false });
        }
        //结算金额
        function onFinalTotalCostRMBClick(ClaimsNumber)
        {
            if(!$powers["r索赔管控_结算录入"])
            {
                $.messager.alert('提示','您没有权限进行此操作');
                return false;
            }
            var rel="UClaimDemageControlUpdateFinalDetail";
            var url="UserModel/UClaimDemageControlUpdateFinalDetail.aspx?ClaimsNumber="+ClaimsNumber;
            var title="索赔结算明细[品情单号:"+ClaimsNumber+"]";
           // var options = {width:850,height:450,max:false,mask:true,maxable:false,minable:false,fresh:true,resizable:false,drawable:true};
            //top.$.pdialog.open(url, rel, title, options);
            top.navTab.openTab(rel, url, { title: title, fresh: true, external: false });
        }
        //索赔成本差异
        function onFinalDiffAmountClick(ClaimsNumber)
        {
            if(!$powers["r索赔管控_差异分析"])
            {
                $.messager.alert('提示','您没有权限进行此操作');
                return false;
            }
            var rel="UClaimDemageControlDiffAnalyse";
            var url="UserModel/UClaimDemageControlDiffAnalyse.aspx?ClaimsNumber="+ClaimsNumber;
            var title="索赔成本差异分析[品情单号:"+ClaimsNumber+"]";
            var options = {width:850,height:320,max:false,mask:true,maxable:false,minable:false,fresh:true,resizable:false,drawable:true};
            top.$.pdialog.open(url, rel, title, options);
        }
         //索赔收入差异
        function onSupplerDiffAmountClick(ClaimsNumber)
        {
            if(!$powers["r索赔管控_差异分析"])
            {
                $.messager.alert('提示','您没有权限进行此操作');
                return false;
            }
            var rel="UClaimDemageControlDiffAnalyse";
            var url="UserModel/UClaimDemageControlDiffAnalyse.aspx?ClaimsNumber="+ClaimsNumber;
            var title="索赔收入差异[品情单号:"+ClaimsNumber+"]";
            var options = {width:850,height:320,max:false,mask:true,maxable:false,minable:false,fresh:true,resizable:false,drawable:true};
            top.$.pdialog.open(url, rel, title, options);
        }
    </script>
    <script>
        //操作功能JS

        //打开高级查找窗口
        function onAdjSearch() {
            $("#tab_search").dialog("open");
            $("#search-buttons").find("#btn_search").click(function () {
                var query = $("#tab_search").serializeJSON(); // GetInputData("tab_search", "query");
                query.action = "query";
                $('#tab_list').datagrid("options").queryParams = query;
                $('#tab_list').datagrid('load');
                $("#tab_search").dialog("close");
                return false;
            });
        }
        //添加
        function onAddClick() {
                
            var rel = "UClaimDemageControlAdd";
            var url = "UserModel/UClaimDemageControlAdd.aspx" ;
            var title = "添加代理商索赔完成报告单";
            var options = { width: 850, height: 450, max: false, mask: true, maxable: false, minable: false, fresh: true, resizable: false, drawable: true };
            top.$.pdialog.open(url, rel, title, options);
            return false;
        }

        //修改，通过工具栏
        function onEditClick() {           

            var row = $('#tab_list').datagrid('getSelected')
            if(row==null)
            {
                $.messager.alert('提示','请先选择要修改的品情单'); 
                return false;
            }  
            var ClaimsNumber=row.ClaimsNumber;
            var rel = "UClaimDemageControlEdit";
            var url = "UserModel/UClaimDemageControlEdit.aspx?ClaimsNumber=" + ClaimsNumber;
            var title = "修改代理商索赔完成报告单";
            var options = { width: 850, height: 450, max: false, mask: true, maxable: false, minable: false, fresh: true, resizable: false, drawable: true };
            top.$.pdialog.open(url, rel, title, options);
            return false;
        }
        //删除
        function onDelClick() {           

            var row = $('#tab_list').datagrid('getSelected')
            if (row == null) {
                $.messager.alert('提示', '请先选择要删除的品情单');
                return false;
            }
            var ClaimsNumber = row.ClaimsNumber;


            $.messager.confirm('提示', '您确认要删除此品情单吗？', function (r) {
                if (r) {
                    var ClaimsNumber = row.ClaimsNumber;
                    var url = "sysAjaxDone.ashx?ajaxmethod=DeleteUClaimDemageControl&ClaimsNumber=" + ClaimsNumber;
                    top.ajaxTodo(url, "");
                    $("#tab_list").datagrid("load");

                }
            });


            return false;
        }

        //导出管控表
        function onExportList() {
            
            var href = "ExportExecl/ExportExeclUClaimDemageControlList.aspx?" + jQuery.param($("#tab_search").serializeJSON());
            top.window.open(href, "");
            return false;
        }
        //向供应商索赔统计表
        function onUClaimDemageControlSupplerTongJi() {           

            var rel = "UClaimDemageControlSupplerTongJi";
            var url = "UserModel/UClaimDemageControlSupplerTongJi.aspx";
            var title = "向供应商索赔统计表";
            top.navTab.openTab(rel, url, { title: title, fresh: true, external: false });
        }

    </script>
</head>
<body style="margin:2px;" >
    <div id="tab_list"></div>
    <div id="tab_toolbar" style="padding:2px;">
       <a href="#" title="高级查找" class="easyui-linkbutton" iconcls="icon-search" plain="true" onclick="return　onAdjSearch(this);" Permission="">高级查找</a>
       <a href="#" title="添加品情单" class="easyui-linkbutton" iconcls="icon-add" plain="true" onclick="return 　onAddClick()" Permission="r新增">添加品情单</a>
       <a href="#" title="修改" class="easyui-linkbutton" iconcls="icon-save" plain="true" onclick="return　onEditClick();" Permission="r修改">修改品情单</a>
       <a href="#" title="删除" class="easyui-linkbutton" iconcls="icon-remove" plain="true" onclick="return　onDelClick();" Permission="r删除">删除</a>      
      
       <a href="#"  class="easyui-linkbutton" iconcls="icon-btnDown" plain="true" onclick="return onExportList();" Permission="r导出">导出管控表</a>
       <a href="#"  class="easyui-linkbutton" iconcls="icon-btnEditMoney" plain="true" onclick="return onSupplerTotalCostRMBClick('');" Permission="r索赔管控_索赔录入">索赔录入</a>
       <a href="#"  class="easyui-linkbutton" iconcls="icon-btnEditMoney" plain="true" onclick="return onFinalTotalCostRMBClick('');" Permission="r索赔管控_结算录入">结算录入</a>
       <a href="#"  class="easyui-linkbutton" iconcls="icon-btnDiffAnalyse" plain="true" onclick="return onUClaimDemageControlSupplerTongJi();" Permission="r索赔管控_向供应商索赔统计">向供应商索赔统计表</a>

       <a href="#"  class="easyui-linkbutton" iconcls="icon-btnDiffAnalyse" plain="true" onclick="return onUClaimDemageControlSupplerTongJi();" Permission="r索赔管控_向供应商索赔统计">向供应商索赔统计表</a>
    </div>   
    <div id="tab_search" title="查询条件" style=" height:250px; width:500px;" class="easyui-dialog" modal="true" closed="true" buttons="#search-buttons">
        <table class="table_search" width="100%" style=" line-height:21px;">
            <tr>
                <td>经销商:</td>
                <td><input  name="ShowAgentName"  class="autocomplete" autocompletehref="<%=AutoCompleteRequestUrl %>?ajaxmethod=getagentlist" mustMatch="true" swidth="300" showinputid=""/></td>
            </tr>
            <tr>
                <td>品情单号:</td>
                <td><input  name="ClaimsNumber" value="" /></td>
            </tr>
            <tr>
                <td>机号:</td>
                <td><input  name="SerialNumber" value="" /></td>
            </tr>
            <tr>
                <td>
                    接到故障日：
                </td>
                <td>                    
                    从<input name="DownlineDateFrom" class="easyui-datebox" type="text" value="" />
                    到<input name="DownlineDateTo" type="text" class="easyui-datebox" value="" />
                </td>
            </tr>
            <tr>
                <td>IHISCE责任:</td>
                <td>                     
                    <select name="DiffDuty" class="easyui-combobox">
                        <option value="" >请选择....</option>
                        <option value="厂内组装" >厂内组装</option>
                        <option value="营业政策性索赔" >营业政策性索赔</option>
                        <option value="特殊索赔约定" >特殊索赔约定</option>
                        <option value="其它">其它</option>
                    </select>
                </td>
            </tr>
        </table>
        <div id="search-buttons">
            <a id="btn_search" href="javascript:;" class="easyui-linkbutton" iconcls="icon-search" plain="true">提交</a> 
            <a href="javascript:;" class="easyui-linkbutton" onclick="$('#tab_search').dialog('close');return false;" iconcls="icon-cancel" plain="true">取消</a>
        </div>
    </div>
</body>
</html>